﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using FarseerPhysics.Dynamics.Contacts;
using MapLibrary.Sound;
using Microsoft.Xna.Framework.Audio;

namespace MapLibrary.Players.Skills
{
    class DoubleJump : Ability
    {

        Player player;

        public DoubleJump(Player p)
        {
            player = p;
        }

        public override void Update()
        {
            
        }

        public override void Activate(Player p)
        {
            //if (p.Type.CurrentState.Equals("Running Left"))
            //{
            //    p.Body.LinearVelocity = new Vector2(p.Body.LinearVelocity.X, 0);
            //    p.Body.ApplyForce(new Vector2(-20, -5000));
            //    p.NumberJumps += 1;
            //}

            //if (p.Type.CurrentState.Equals("Running Right"))
            //{
            //    p.Body.LinearVelocity = new Vector2(p.Body.LinearVelocity.X, 0);
            //    p.Body.ApplyForce(new Vector2(20, -5000));
            //    p.NumberJumps += 1;
            //}
            //if(p.IsRunning() || p.IsLanding() ||

            //if (p.Type.CurrentState.Equals("Landing") ||
            //    p.Type.CurrentState.Equals("Idle"))
            //{
            //    p.Body.LinearVelocity = new Vector2(p.Body.LinearVelocity.X, 0);
            //    p.Body.ApplyForce(new Vector2(0, -5000));
            //    p.NumberJumps += 1;
            //}

            //if (p.Type.CurrentState.Equals("Jumping"))
            //{
            //    p.Body.LinearVelocity = new Vector2(p.Body.LinearVelocity.X, 0);
            //    p.Body.ApplyForce(new Vector2(0, -5000));
            //    p.NumberJumps += 1;
            //}
            p.Body.LinearVelocity = new Vector2(p.Body.LinearVelocity.X, 0);
            p.Body.ApplyForce(new Vector2(0, -5000));
            p.NumberJumps += 1;

            p.EnterStateWithProperDirection("Jumping");

            SoundManager.GetSoundManager().PlayCue("nanobot_jump");
        }

        public override bool ActivateConditionsSatisfied(Player p)
        {
            return ((p.NumberJumps == 0) || ((p.NumberJumps == 1) && (IsAvailable)));
        }
    }
}
